package game.model;

import com.sghd.common.utils.model.RatioProbability;

import java.util.Map;

/**
 * \* Created: fank
 * \* Date: 2018/5/21
 * \* Time: 12:20
 * \* @desc:
 */
public class ConfigRoom {

    private Integer id;
    private Integer gameId;
    private String roomName;
    /** 房间id*/
    private Integer roomId;
    /**下注区域*/
    private Integer[] betArea;
    /**入场金币限制区间数组*/
    private Long[] limitMoney;
    /**(索引对应)普通元素个数对应倍数 key=元素枚举索引, vlaue=元数个数对应的奖励倍数*/
    private Map<Integer, Map<Integer, Integer>> count2Rate;
    /** 免费旋转次数*/
    private Integer freeCount;
    /**多少张桌子*/
    private Integer deskCount;
    /** 普通旋转每个元素出现的概率权重数组JSON, 按{@link com.sghd.football.module.game.service.core.ChessType}索引来*/
    private Integer[] rates;
    /** 免费旋转每个元素出现的概率权重数组JSON, 按{@link com.sghd.football.module.game.service.core.ChessType}索引来*/
    private Integer[] ratesFree;
    /** 奖励等级*/
    private Integer[] rewardRang;
    /** 抽水比例 + 反分池比例 = 1*/
    /** 抽水比例*/
    private Float drawWaters;
    /** 反分池比例*/
    private Float refund;
    /** 反分也缓冲值<压注档位， [下限倍数，上限倍数]>*/
    private Map<Integer, int[]> refundCtrl;
    /** 连击次数对应小游戏*/
    private Map<Integer, Integer> mgame;
    /** 三朵花的倍数和权重的关系*/
    private RatioProbability<Float> flower;
    /** 三个飞镖，免费次数和权重的关系*/
    private RatioProbability<Integer> dart;
    /** 购买次数对应总押倍数*/
    private Map<Integer, Integer> buy2Bet;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getGameId() {
        return gameId;
    }

    public void setGameId(Integer gameId) {
        this.gameId = gameId;
    }

    public String getRoomName() {
        return roomName;
    }

    public void setRoomName(String roomName) {
        this.roomName = roomName;
    }

    public Integer getRoomId() {
        return roomId;
    }

    public void setRoomId(Integer roomId) {
        this.roomId = roomId;
    }

    public Integer[] getBetArea() {
        return betArea;
    }

    public void setBetArea(Integer[] betArea) {
        this.betArea = betArea;
    }

    public Long[] getLimitMoney() {
        return limitMoney;
    }

    public void setLimitMoney(Long[] limitMoney) {
        this.limitMoney = limitMoney;
    }

    public Map<Integer, Map<Integer, Integer>> getCount2Rate() {
        return count2Rate;
    }

    public void setCount2Rate(Map<Integer, Map<Integer, Integer>> count2Rate) {
        this.count2Rate = count2Rate;
    }

    public Integer getFreeCount() {
        return freeCount;
    }

    public void setFreeCount(Integer freeCount) {
        this.freeCount = freeCount;
    }

    public Integer getDeskCount() {
        return deskCount;
    }

    public void setDeskCount(Integer deskCount) {
        this.deskCount = deskCount;
    }

    public Integer[] getRates() {
        return rates;
    }

    public void setRates(Integer[] rates) {
        this.rates = rates;
    }

    public Integer[] getRatesFree() {
        return ratesFree;
    }

    public void setRatesFree(Integer[] ratesFree) {
        this.ratesFree = ratesFree;
    }

    public Integer[] getRewardRang() {
        return rewardRang;
    }

    public void setRewardRang(Integer[] rewardRang) {
        this.rewardRang = rewardRang;
    }

    public Float getDrawWaters() {
        return drawWaters;
    }

    public void setDrawWaters(Float drawWaters) {
        this.drawWaters = drawWaters;
    }

    public Float getRefund() {
        return refund;
    }

    public void setRefund(Float refund) {
        this.refund = refund;
    }

    public Map<Integer, int[]> getRefundCtrl() {
        return refundCtrl;
    }

    public void setRefundCtrl(Map<Integer, int[]> refundCtrl) {
        this.refundCtrl = refundCtrl;
    }

    public Map<Integer, Integer> getMgame() {
        return mgame;
    }

    public void setMgame(Map<Integer, Integer> mgame) {
        this.mgame = mgame;
    }

    /**
     * 连击次数对应游戏次数
     * */
    public int getMGame(int size) {
        int max = mgame.keySet().stream().sorted((o1, o2) -> -1).findFirst().get();
        if (size > max) {
            return mgame.get(max);
        }
        if (mgame.containsKey(size)) {
            return mgame.get(size);
        }
        return 0;
    }

    /***/
    public void setDart(Map<Integer, Integer> ratio) {
        this.dart = RatioProbability.valueOf(ratio);
    }

    /***/
    public void setFlower(Map<Float, Integer> ratio) {
        this.flower = RatioProbability.valueOf(ratio);
    }

    public float getScope(MType mGame) {
        if (mGame == MType.FLOWER) {//花
            return flower.getResult();
        }
        if (mGame == MType.DART) {//飞镖
            return dart.getResult();
        }
        throw new RuntimeException("获取[{}]属性值发生未知错误！");
    }

    public RatioProbability<Float> getFlower() {
        return flower;
    }

    public void setFlower(RatioProbability<Float> flower) {
        this.flower = flower;
    }

    public RatioProbability<Integer> getDart() {
        return dart;
    }

    public void setDart(RatioProbability<Integer> dart) {
        this.dart = dart;
    }

    public Map<Integer, Integer> getBuy2Bet() {
        return buy2Bet;
    }

    public void setBuy2Bet(Map<Integer, Integer> buy2Bet) {
        this.buy2Bet = buy2Bet;
    }
}
